package baseTest;

public class Rotate2 {
    public static void main(String[] args) {

    }

    public void process(int[][] matrix){
        int tR = 0;
        int tC = 0;
        int dR = matrix.length-1;
        int dC = matrix[0].length-1;

        while (tR < dR){
            reverse(matrix,tR++,tC++,dR--,dC--);
        }
    }

    public void reverse(int[][] matrix,int tR, int tC,int dR, int dC){
        int times = dC -dR;
        int temp = 0;
        for (int i = 0; i < times; i++) {
            temp = matrix[tR][tC+i];
            matrix[tR][tC+i] = matrix[dR - i][tC];
            matrix[dR-i][tC] = matrix[dR][dC-i];
            matrix[dR][dC-i] = matrix[tR+i][dC];
            matrix[tR+i][dC] =  temp;
        }
    }
}
